D) numeric.hpp

#include <numeric>
std::iota(from C++11)
template <class FowardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value){
while(first!=last){
*first++=value;
++value;
}
}
Fills the range [first, last) with sequentially incressing values,
starting with value and repetetively evaluating ++value;

컨테이너의 begin()부터 end()까지 value에서 1씩 증감
std::accumulate
template <class InputIt, class T>
constexpr T accumulatte(InputIt first, Inputit last, T init){
for(; first!=last; ++first){
init=std::move(init)+*first;
}
return init;
}
template <class InputIt, class T, class BinaryOperation>
constexpr T accumulate(InputIt first, InputIt last, T init, BinaryOperation op){
for(; first!=last; ++first){
init=op(std::move(init), *first);
}
return init;
}
std::inner_product
template <class InputIt1, class InputIt2, class T>
constexpr T inner_product(InputIt1 first1, InputIt1 last, InputIt2 first2, T init){
while(first!=last1){
init=std::move(init)+*first1* *first2;
++first1;
++first2;
}
return init;
}
template <class InputIt1, class InputIt2, class T, class BinaryOperation1, class BinaryOperation2>
T inner_proudct(InputIt1 first1, InputIt1 last1, InputIt2 first2, T init, BinaryOperation1 op1, BinaryOperation2 op2){
while(first!=last1){
init=op1(std::move(init), op2(*first1, *first2));
++first1;
++first2;
}
return init;
}
std::adjacent_difference
computes the differences between the second and
the first of each adjacent pair of elements of the range

*(d_first)=*first;
*(d_first+1)=*(first+1)-*(first);
*(d_first+2)=*(first+2)-*(fisrt+1);
    ...
template <class InputIt, class OutputIt>
constexpr OuputIt adjacent_differenc(InputIt first, InputIt last, OutputIt d_first){
if(first==last) return d_first;
typedef typename std::iterator_traits<InputIt>::value_type value_t;
value_t acc=*first;
*d_first=acc;
while(++first!=last){
value_t val=*first;
*++d_first=val-std::move(acc);
acc=std::move(val);
}
return ++d_first;
}
template <class InputIt, class OutputIt, class BinaryOperation>
constexpr OuputIt adjacent_defference(InputIt first, InputIt last, OutputIt d_first, BinaryOperation op){
if(first==last) return d_first;
typedef typename std::iterator_traits<InputIt>::value_type value_t;
value_t acc=*first;
*d_first=acc;
while(++first!=last){
value_t val=*first;
*++d_fist=op(val, std::move(acc));
acc=std::move(val);
}
return ++d_first;
}
std::partial_sum
Computes the partial sum of the elements in the subranges of the range

*(d_first)=*first;
*(d_first+1)=*first+*(first+1);
*(d_first+2)=*first+*(first+1)+*(first+2);
    ...
template <class InputIt, class OutputIt>
constexpr OutputIt partial_sum(InputIt first, InputIt last, OutputIt d_first){
if(first==last) return d_first;
typename std::iterator_traits<InputIt>::value_type sum=*first;
*d_first=sum;
while(++first!=last){
sum=std::move(sum)+*first;
*++d_first=sum;
}
return ++d_first;
}
template <class InputIt, class OutputIt, class BinaryOperation>
constexpr OuputIt partial_sum(InputIt first, InputIt last, OuputIt d_first, BinaryOperation op){
if(first==last) return d_first;
typename std::iterator_traits<InputIt>::value_type sum=*first;
*d_first=sum;
while(++first!=last){
sum=op(std::move(sum), *first);
*++d_first=sum;
}
return ++d_first;
}